package com.baizan.daka.ui.activity

import android.content.Context
import android.content.Intent
import androidx.fragment.app.Fragment
import com.baizan.base.BaseActivity
import com.baizan.daka.base.BasePresenter
import com.baizan.daka.ui.fragment.TaskMgrFragment
import com.dianzan.daka.R
import com.xinfang.louxun.base.adapter.BaseFragmentAdapter
import kotlinx.android.synthetic.main.act_show_cash.*
import java.util.ArrayList

class TaskMgrActivity : BaseActivity<BasePresenter>() {
    private val mTitles = arrayOf("全部", "未结束", "已结束")

    private val mTabTitleList = ArrayList<String>()
    private var mFragmentList = ArrayList<Fragment>()

    var adapter: BaseFragmentAdapter? = null

    companion object {
        fun start(context: Context) {
            context.startActivity(Intent(context, TaskMgrActivity::class.java))
        }
    }

    override fun initPresenter(): BasePresenter? = null

    override fun layoutId(): Int = R.layout.act_task_mgr

    override fun initData() {
        adapter = BaseFragmentAdapter(supportFragmentManager, mFragmentList, mTabTitleList)
        mViewPager.setAdapter(adapter)
        initTab()
    }

    private fun initTab() {

        mFragmentList.add(TaskMgrFragment.newInstance(null))
        mFragmentList.add(TaskMgrFragment.newInstance(0))
        mFragmentList.add(TaskMgrFragment.newInstance(1))

        adapter?.recreateItems(mFragmentList, mTitles)
        mTabLayout.setViewPager(mViewPager, mTitles)
    }

    override fun initView() {

    }

    override fun start() {
    }

}